<template>
  <h2>添加敏感词</h2>
  <el-form :model="sensitiveWord" :rules="rules" ref="registerRef" style="margin-top: 50px">
    <el-form-item label="敏感词" prop="word">
      <el-input v-model="sensitiveWord.word" style="width: 20%"/>
    </el-form-item>
    <el-form-item style="margin-top: 50px">
      <el-button type="primary" @click="addSensitive" style="margin-left: 50px;width: 100px">确定</el-button>
      <el-button type="warning" style="margin-left: 50px;width: 100px">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {ref} from "vue";
import {addSensitiveWord} from "../../apis/SensitiveWordApi.js";
import {elPrompt} from "../../utils/elPrompt.ts";

const sensitiveWord = ref({
  word:''
})

const registerRef = ref()
const rules=ref({
  // word:[{ validator:checkWord,trigger: 'blur'}],
})

function addSensitive(){
    addSensitiveWord(sensitiveWord.value, (result) => {
      console.log(sensitiveWord.value)
      if (result.status === 200){
        elPrompt("添加成功","success")
      }else{
        elPrompt("添加失败","error")
      }
    })
}
</script>

<style scoped>

</style>
